<?php
namespace App\Domain\Appfc114;
use Illuminate\Database\Capsule\Manager as DB;

class QueryScore
{
    //统计用户积分
    public function userScore($user_id)
    {
        //统计用户客户积分=客户数*10
        $total = DB::table('crm_customer')
            ->where("flag",1)
            ->where("owner_uid",$user_id)
            ->count();
        $customer_score = $total*10;
        //统计用户报备积分=报备数*20
        $total = DB::table('crm_visit')
            ->where("flag",1)
            ->where("owner_uid",$user_id)
            ->count();
        $visit_score = $total*10;

        $score = $customer_score + $visit_score;
        return $score;
    }

}
